package com.service.impl;

import com.entity.Dept;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.DeptMapper;
import com.service.IDeptService;
import com.until.ConstantUtil;
import com.vo.Page;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;


@Service
public class DeptServiceImpl implements IDeptService {
    @Resource
    private DeptMapper deptMapper;

    @Override
    public List<Dept> listAll() {
        Dept dept=new Dept();
        dept.setDeptStatus(ConstantUtil.DeptStatus.ENABLED);
        System.out.println(dept);
        return deptMapper.listByParam(dept);
    }

    @Override
    public PageInfo<Dept> listByParam(Page<Dept> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());

        return new PageInfo<Dept>(deptMapper.listByParam(page.getData()));
    }

    @Override
    public Dept getByDeptId(Integer deptId) {
        return deptMapper.getByDeptId(deptId);
    }

    @Override
    public int insert(Dept dept) {
        return deptMapper.insert(dept);
    }

    @Override
    public int delete(Integer deptId) {
        return deptMapper.delete(deptId);
    }

    @Override
    public int update(Dept dept) {
        return deptMapper.update(dept);
    }
}
